"""create_demo_data

Revision ID: 7fad9851701a
Revises: 4f53b890a11f
Create Date: 2017-03-12 14:25:42.163065

"""

# revision identifiers, used by Alembic.
revision = '7fad9851701a'
down_revision = '4f53b890a11f'

from alembic import op
import sqlalchemy as sa
from database import db
from mall.models.currency import Currency
from mall.models.account import Account
from mall.models.member import Member
from mall.models.offer import Offer
from mall.models.product import Product
from mall.models.offer import Offer
from mall.models.product import Product
from mall.models.resource import Resource
import mall
import random


def upgrade():
    pass
    # product_list =  Product.query.all()
    #
    # currency_list = Currency.query.all()
    # resource_list = Resource.query.all()
    # for i in range(0, 5):
    #     start = random.randint(100000, 999999)
    #     account_id = str(start).zfill(20)
    #     account = Account(id='01-{}'.format(account_id),
    #                       balance=150.00,
    #                       currency=random.choice(currency_list)
    #                       )
    #
    #     member = Member(id=account_id,
    #                     screen_name='市场用户 {} '.format(str(1)),
    #                     account=account,
    #                     head_image=random.choice(resource_list)
    #                     )
    #     db.session.add(account)
    #     db.session.add(member)
    #     for x  in  range(0,3):
    #         offer = Offer(
    #             dealer = member,
    #             count = random.randint(1,10),
    #             slug = 'CD-KEY',
    #             price = random.uniform(1,20),
    #             product = random.choice(product_list)
    #         )
    #         db.session.add(offer)
    #     db.session.commit()

        ### commands auto generated by Alembic - please adjust! ###
        # op.alter_column('product', 'cover_resource_id',
        #            existing_type=sa.VARCHAR(length=300),
        #            nullable=True)
        # op.alter_column('product', 'sub_title',
        #            existing_type=sa.VARCHAR(length=400),
        #            nullable=False)
        # op.alter_column('product', 'title',
        #            existing_type=sa.VARCHAR(length=400),
        #            nullable=False)
        # op.drop_column('product', 'cover')
        ### end Alembic commands ###


def downgrade():
    ### commands auto generated by Alembic - please adjust! ###
    # op.add_column('product', sa.Column('cover', sa.VARCHAR(length=400), nullable=True))
    # op.alter_column('product', 'title',
    #            existing_type=sa.VARCHAR(length=400),
    #            nullable=True)
    # op.alter_column('product', 'sub_title',
    #            existing_type=sa.VARCHAR(length=400),
    #            nullable=True)
    # op.alter_column('product', 'cover_resource_id',
    #            existing_type=sa.VARCHAR(length=300),
    # nullable = False)
    ### end Alembic commands ###
    pass
